import 'package:flutter/material.dart';
import 'package:get/get.dart';

import 'index.dart';

class TabSubPage extends StatelessWidget {
  TabSubPage({
    Key? key,
    required this.tag,
  })  : controller = Get.put(TabSubController(), tag: '$tag'),
        super(key: key);
  final int tag;
  final TabSubController controller;

  // 主视图
  Widget _buildView() {
    return ListView.builder(
      itemBuilder: (context, index) {
        return ListTile(
          title: Text('$tag ---- $index'),
        );
      },
      itemCount: 10,
    );
  }

  @override
  Widget build(BuildContext context) {
    return GetBuilder<TabSubController>(
      tag: '$tag',
      builder: (_) {
        Get.log(controller.hashCode.toString());
        return Scaffold(
          appBar: AppBar(title: const Text("tab_sub")),
          body: SafeArea(
            child: _buildView(),
          ),
        );
      },
    );
  }
}
